package com.syyo.gulimall.product.app;

//import org.springframework.security.access.prepost.PreAuthorize;

import com.syyo.common.domain.ResultVo;
import com.syyo.common.utils.ResultUtils;
import com.syyo.gulimall.product.domain.req.SpuInfoDescReq;
import com.syyo.gulimall.product.service.SpuInfoDescService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * spu信息介绍
 *
 * @author syyo
 * @email syyo@gmail.com
 * @date 2021-01-20 09:32:12
 */
@RestController
@RequestMapping("/product/spuinfodesc")
public class SpuInfoDescController {

    @Autowired
    private SpuInfoDescService spuInfoDescService;

    /**
     * 新增
     */
    @PostMapping
    // @PreAuthorize("@syyo.check('system:spuinfodesc:add')")
    public ResultVo add(@RequestBody SpuInfoDescReq req) {
        return ResultUtils.ok(spuInfoDescService.add(req));
    }

    /**
     * 删除
     */
    @DeleteMapping("/{id}")
    // @PreAuthorize("@syyo.check('system:spuinfodesc:del')")
    public ResultVo del(@PathVariable("id") Integer id) {
        return ResultUtils.ok(spuInfoDescService.del(id));
    }

    /**
     * 修改
     */
    @PutMapping
    // @PreAuthorize("@syyo.check('system:spuinfodesc:edit')")
    public ResultVo edit(@RequestBody SpuInfoDescReq req) {
        return ResultUtils.ok(spuInfoDescService.edit(req));
    }

    /**
     * 信息
     */
    @GetMapping("/{id}")
    public ResultVo findOne(@PathVariable("id") Integer id) {
        return ResultUtils.ok(spuInfoDescService.findOne(id));
    }

    /**
     * 列表
     */
    @GetMapping("/list/{pageNum}/{pageSize}")
    public ResultVo findAll(@PathVariable("pageNum") Integer pageNum,
                            @PathVariable("pageSize") Integer pageSize,
                            SpuInfoDescReq req) {
        return ResultUtils.ok(spuInfoDescService.findAll(pageNum, pageSize, req));
    }

}
